Skip to main content

Cache Time to Live

(MI.CachePolicy)

Overview

The Cache Time to Live (TTL) rule lets you set caching policies to determine how long content is cached on the CDN before it is considered stale. The rule can also control how long content is cached on the client side. Client TTL causes cache-control headers to be added to the response.

Note the following:

  • By default, the Cache TTL policies in the HTTP response from the origin override the Cache TTL policies defined by the feature configuration.
  • By default, the feature configuration's cache TTL settings are used only when the origin response does not include TTL directives.
  • You can override the default behaviors as part of the feature configuration.

Basic example:

{
"generic-metadata-type": "MI.CachePolicy",
"generic-metadata-value": {
"force-external": false,
"internal": "3600",
"external": "as-is",
"force-internal": true
}
}

This example configuration sets the following Cache TTL behaviors:

  • "internal": "3600" - The CDN TTL is set to 3600 seconds
  • "force-internal": true - The CDN TTL settings override any TTL settings in the origin response.
  • "force-external": false** and **"external": "as-is" - No client TTL behavior is specified.

Note that "internal" represents the CDN TTL behavior, while "external" represents the Client TTL behavior.

Examples

Example 1: Set Explicit TTL Values for CDN and Client

{
"generic-metadata-type": "MI.CachePolicy",
"generic-metadata-value": {
"internal": "86400",
"external": "86400",
"force-internal": true,
"force-external": false
}
}


In this example:

  • The TTL is set for a week, for both the CDN cache (internal) and client cache (external).
  • "force-internal": true - The CDN TTL setting overrides any TTL settings in the origin response
  • "force-external": false - The client TTL setting does not override TTL settings in the response.

Example 2: Long TTL for CDN, Default Behavior for Client

{
"generic-metadata-type": "MI.CachePolicy",
"generic-metadata-value": {
"internal": "31536000",
"external": "as-is",
"force-internal": false,
"force-external": false
}
}


In this example:

  • "internal": "31536000" (seconds) - The CDN TTL is set for a year ( seconds) with no origin override.
  • "force-internal": false - The client TTL is not configured.
  • "external": "as-is"- TTL parameters defined in the HTTP response from the origin are used.

Example 3: Disable All Caching

This example directs both the CDN and the client to retrieve all content requests from the origin.

{
"generic-metadata-type": "MI.CachePolicy",
"generic-metadata-value": {
"internal": "no-store",
"external": "no-store",
"force-internal": true,
"force-external": true
}
}

Supported Properties

FieldDescriptionValid Values
force-externalDetermines if the cache policy set by the client (external) overrides any cache policy set by the origin.true, false
internalThe CDN caching policy. Enter any integer to specify the CDN TTL in seconds or specify a different behavior.- <number of seconds>
- as-is: Use the TTL parameters defined in the HTTP response from the origin.
- no-cache: Revalidate with the origin before serving the cached content.
- no-store: Send all requests to the origin. Do not cache content.
externalThe client caching policy. Enter any integer to specify the client TTL in seconds or specify a different behavior.- <number of seconds>
- as-is: Use the TTL parameters defined in the HTTP response from the origin.
- no-cache: Revalidate with the origin before serving the cached content.
- no-store: Send all requests to the origin. Do not cache content.
force-internalDetermines if the cache policy set by the CDN (internal) overrides any cache policy set by the origin.true, false